package chinaums2

import (
    "fmt"
	//"errors"
	//"strings"
	"encoding/xml"
	"thirdpaysdk/utils/mapstruct"
	//"github.com/astaxie/beego"
)

type OceanPayMsg struct {
	OrderNo     string  `form:"OrderNo"`
    PayNo       string  `form:"PayNo"`
	PayAmount   float32 `form:"PayAmount"`
	CurrCode    string  `form:"CurrCode"`
	SystemSSN   string  `form:"SystemSSN"`
	RespCode    string  `form:"RespCode"`
	SettDate    string  `form:"SettDate"`
    Reserved01  string  `form:"Reserved01,omitempty"`
	Reserved02  string  `form:"Reserved02,omitempty"`
	SignMsg     string  `form:"SignMsg"`
}

func OceanPayMsgNotify(body []byte) (map[string]string, error){
	var response OceanPayMsg
	err := xml.Unmarshal(body, &response)
	if err != nil {
		return map[string]string{}, err
	}
	rspMap :=  mapstruct.Struct2Map(response, "xml")
	reqMap := make(map[string]string)
	for k, v := range rspMap {
		reqMap[k] = fmt.Sprintf("%v", v)
	}
	return reqMap, nil
}
